<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>从小到大排序</title>
</head>
<body>
    <script>
function sort(array){
    for(var i = 1;i < array.length;i++);{
        for (var j = i;j>0;j--){
            if(array[j-1]>array[j]){
                var temp = array[j-1];
                array[j-1] = array[j];
                array[j] = temp;
            }
        }
    }
    return array;
}
var nums = prompt("请输入一组用逗号隔开的数字:");
var newarray = nums.split(",");
alert(sort(newarray));
    </script>
</body>
</html>